package autonomrobot;

import java.awt.Image;

/**
 *
 * @author Ragnar
 */
public class ImageResource
{
    private Image image;
    private boolean isAvailable;
    
    public ImageResource()
    {
        this.image = null;
        this.isAvailable = false;
    }
    
    public synchronized void putImage(Image img)
    {
        if (!this.isAvailable)
        {
            this.image = img;
            this.isAvailable = true;
        }
    }
    
    public synchronized Image getImage()
    {
        if (this.isAvailable)
        {
            this.isAvailable = false;
            return this.image;
        }
        return null;
    }
}
